var RunLayer_14 = cc.Layer.extend({
	arr:null,
	scene:null,
	clock:null,
	ctor:function (parent) {
		this._super();
		this.scene = parent;
		this.scene.addChild(this, 10);
		gg.main = this;
		this.init();
	},
	init:function () {
		this.callNext = cc.callFunc(function(){
			gg.flow.next();
		}, this);
		this.callKill = cc.callFunc(function(p){
			var seq = cc.sequence(cc.fadeOut(0.5),cc.callFunc(function(){
				p.removeFromParent(true);	
			}, this));
			p.runAction(seq);
		}, this); 
		
		this.callNext.retain();
		this.callKill.retain();
		//时钟
		this.clock = new Clock(this);
		// 物品库
		this.lib = new Lib(this);
		this.lib.loadBg([
		                 {tag:TAG_LIB_CANDLE},
		                 {tag:TAG_LIB_PULLEY,checkright:true},
		                 {tag:TAG_LIB_MACHINERY},
		                 {tag:TAG_LIB_HOOKCODE,checkright:true},
		                 {tag:TAG_LIB_BULB},
		                 {tag:TAG_LIB_BOARD},
		                 {tag:TAG_LIB_PLASTIC,checkright:true},
		                 {tag:TAG_LIB_MIRROR},
		                 {tag: TAG_LIB_SWITCH},
		                 {tag:TAG_LIB_WIREWAY}
		                 ]);
		this.pulley = new Pulley(this);
		this.pulley.setVisible(false);
		this.hookcode = new HookCode(this);
		this.hookcode.setVisible(false);
		this.plastic = new Plastic(this);
		this.plastic.setVisible(false);
	},
	checkVisible:function(next){
		//是否可见
		var checkVisible = [];		
		var pulley = ll.run.getChildByTag(TAG_PULLEY);	
		var hookcode = ll.run.getChildByTag(TAG_CODE);
		var plastic = ll.run.getChildByTag(TAG_PLASTIC);
		var show = ll.run.getChildByTag(TAG_SHOW);
		checkVisible.push(pulley,hookcode,plastic,show);

		for(var i in checkVisible){
			if(checkVisible[i] !== null){				
				checkVisible[i].setVisible(next);				
			}			
		}
	},
	loadInLib:function(obj, pos, tarPos,delay){
		obj.setPosition(pos);
		if(delay == null){
			delay = 1;
		}
		var ber = $.bezier(pos, tarPos, delay);
		var seq = cc.sequence(ber, this.callNext);
		obj.runAction(seq);
	},
	kill:function(obj){
		var fade = cc.fadeTo(0.5,0);
		var func = cc.callfunc(function(){
			obj.removeFromParent(true);
		},this);
		var seq = cc.sequence(fade,func);
		obj.runAction(seq)
	},
	
	callback:function (p){
		var func = cc.callFunc(this.actionDone, this);
		var action=gg.flow.flow.action;
		switch(p.getTag()){
		case TAG_XIANGPISAI:

		break;
		 
		}
	},
	actionDone:function(p){
		var func = cc.callFunc(this.actionDone, this);
		switch(p.getTag()){
		
		}
	},
	flowNext:function(){
		gg.flow.next();
	},
	onExit:function(){
		this._super();
		this.callNext.release();
		this.callKill.release();

	}
});
